package com.ebpm.designer.dir
{
	import com.ebpm.designer.NodeContainer;
	import com.ebpm.designer.WF;
	import com.ebpm.designer.WP;
	
	import flash.events.MouseEvent;
	
	import mx.containers.Canvas;
	import mx.controls.Image;
	
	import spark.components.Group;
	import spark.primitives.BitmapImage;
	
	//nodeContianer左上角的 拖拽框
	public class NodeContainerLTDir extends Canvas
	{
		[Embed(source="img/nw.png")]
		private static const nwImg:Class;
		public var iconImage:Image;
		public var nodeContainer:NodeContainer;
		
		public function NodeContainerLTDir(userContainer:NodeContainer)
		{
			this.nodeContainer = userContainer;
			this.initIcon();
			this.initStyle();
			this.addEventListener(MouseEvent.MOUSE_OVER, _mouseOver);
			this.addEventListener(MouseEvent.MOUSE_OUT, _mouseOut);
			this.addEventListener(MouseEvent.MOUSE_DOWN, _mouseDown);
			this.addEventListener(MouseEvent.MOUSE_UP, _mouseUp);
		}
		
		public function initStyle():void {
			this.x = 0;
			this.y = 0;
			this.width = WF.ITEM_SIZE;
			this.height = WF.ITEM_SIZE;
		}
		
		private function initIcon():void
		{
//			iconImage = new Image();
//			iconImage.x = 0;
//			iconImage.y = 0;
//			iconImage.width = WF.ITEM_SIZE;
//			iconImage.height = WF.ITEM_SIZE;
//			iconImage.source = "img/nw_resize.png";
//			this.addElement(iconImage);
			
			var titleIcon:Canvas = new Canvas();
			titleIcon.x = 0;
			titleIcon.y = 0;
			titleIcon.width = WF.ITEM_SIZE;
			titleIcon.height = WF.ITEM_SIZE;
			
			var group:Group = new Group();
			var bi:BitmapImage = new BitmapImage();
			bi.source = WF.Icon_LT_Resize;
			bi.width = titleIcon.width;
			bi.height = titleIcon.height;
			group.addElement(bi);
			titleIcon.addElement(group);
			this.addElement(titleIcon);
		}
		
		public function _mouseOver(event:MouseEvent):void
		{
			this.cursorManager.setCursor(nwImg);
		}
		
		public function _mouseOut(event:MouseEvent):void
		{
			this.cursorManager.removeAllCursors();
		}
		
		public function _mouseDown(event:MouseEvent):void
		{
			this.nodeContainer.resizeStartW = this.nodeContainer.width;
			this.nodeContainer.resizeStartH = this.nodeContainer.height;
			this.nodeContainer.startMoveX = this.nodeContainer.x;
			this.nodeContainer.startMoveY = this.nodeContainer.y;
			
			WP.isAllowSelectNodeContainers = false;
			this.nodeContainer.isResizing = true;
			this.nodeContainer.dirType = 1;
		}
		
		public function _mouseUp(event:MouseEvent):void
		{
			this.nodeContainer.isResizing = false;
		}
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
	}
}